﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace iSun.App
{
    public partial class DialogForm : Form
    {
        private string _SN;
        private bool _IsSourceFile;
        private string _venderID;
        private string _productID;
        private IList<iSun.Entity.ProductTemp> _list;
        public DialogForm()
        {
            InitializeComponent();
        }

        public DialogForm(string SN,string ProductID,string Vender_ID,bool IsSourceFile)
        {
            _SN = SN;
            _IsSourceFile = IsSourceFile;
            _venderID = Vender_ID;
            _productID = ProductID;
            InitializeComponent();
        }

        public DialogForm(IList<iSun.Entity.ProductTemp> list, bool IsSourceFile)
        {
            _list = list;
            _IsSourceFile = IsSourceFile;
            InitializeComponent();
        }

        private void DialogForm_Load(object sender, EventArgs e)
        {
            if (_venderID == "")
            {
              _venderID =   DataAction.GetProduct(_productID)[0].Vendor_id.ToString();
            }
            timer1.Start(); 
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Hide();
            this.Close();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.timer1.Stop();
            if (_SN != null)
            {
                DataAction.DownLandFile(_productID, _venderID, _IsSourceFile, this.progressBar2, this.label3, this.label3);
            }
            else
            {
                foreach (iSun.Entity.ProductTemp entity in _list)
                {
                    DataAction.DownLandFile(entity.ProductID, entity.VendorID, _IsSourceFile, this.progressBar2, this.label3, this.label3);
                }
            }
        }
    }
}
